package com.ruoyi.web.controller.dangerControl;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageHelper;
import com.ruoyi.dangerControl.domain.SysDepart;
import com.ruoyi.dangerControl.dto.HdTrainDeptDto;
import com.ruoyi.dangerControl.vo.HdTrainVo;
import com.ruoyi.dangerControl.vo.SysDepartVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dangerControl.domain.HdTrainScore;
import com.ruoyi.dangerControl.service.IHdTrainScoreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 隐患-培训管理-部门Controller
 *
 * @author lth
 * @date 2023-12-20
 */
@RestController
@RequestMapping("/dangerControl/score")
public class HdTrainScoreController extends BaseController
{
    @Autowired
    private IHdTrainScoreService hdTrainScoreService;

    /**
     * 查询隐患-培训管理-部门列表
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:score:list')")
    @GetMapping("/list")
    public TableDataInfo list(HdTrainScore hdTrainScore)
    {
        startPage();
        List<HdTrainScore> list = hdTrainScoreService.selectHdTrainScoreList(hdTrainScore);
        return getDataTable(list);
    }

    /**
     * 导出隐患-培训管理-部门列表
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:score:export')")
    @Log(title = "隐患-培训管理-部门", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HdTrainScore hdTrainScore)
    {
        List<HdTrainScore> list = hdTrainScoreService.selectHdTrainScoreList(hdTrainScore);
        ExcelUtil<HdTrainScore> util = new ExcelUtil<HdTrainScore>(HdTrainScore.class);
        util.exportExcel(response, list, "隐患-培训管理-部门数据");
    }

    /**
     * 获取隐患-培训管理-部门详细信息
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:score:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hdTrainScoreService.selectHdTrainScoreById(id));
    }

    /**
     * 新增隐患-培训管理-部门
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:score:add')")
    @Log(title = "隐患-培训管理-部门", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HdTrainScore hdTrainScore)
    {
        return toAjax(hdTrainScoreService.insertHdTrainScore(hdTrainScore));
    }

    /**
     * 修改隐患-培训管理-部门
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:score:edit')")
    @Log(title = "隐患-培训管理-部门", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HdTrainScore hdTrainScore)
    {
        return toAjax(hdTrainScoreService.updateHdTrainScore(hdTrainScore));
    }

    /**
     * 删除隐患-培训管理-部门
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:score:remove')")
    @Log(title = "隐患-培训管理-部门", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hdTrainScoreService.deleteHdTrainScoreByIds(ids));
    }

    /**
     * 通过部门ID查询部门内人员列表
     *
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:depart:query')")
    @GetMapping("/getDepartPersonList")
    public HdTrainDeptDto getDepartPersonList(@RequestBody HdTrainVo vo){
        HdTrainDeptDto hdTrainDeptDto = hdTrainScoreService.getDepartPersonList(vo);
        return hdTrainDeptDto;
    }


}
